<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/include/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script src="${ctx}/statics/lib/jquery/jquery.min.js" type="javascript/text"></script>
</head>
<body>

<form>
    <!--文件选择input-->
    <h3>文件选择：</h3>
    <input class="btn btn-default" type="file" id="upFile" multiple="multiple"/>
    <!--提交压缩后的base64文件数据给后台-->
    <h3>传给后台</h3>
    <input class="btn btn-default" type="button" id="upTo" value="提交"/>
</form>

<script>

    $("#upTo").click(function () {
        var formData = new FormData();
        for (var i = 0; i < $('#upFile')[0].files.length; i++) {
            formData.append('contractFile', $('#upFile')[0].files[i]);
        }
        $.ajax({
            url: 'http://localhost:8080/chedai/fileUpload.do',
            type: 'POST',
            data: formData,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (returndata) {
                alert(returndata);
            },
            error: function (returndata) {
                alert(returndata);
            }
        });
    });

</script>
</body>
</html>